import React, {useEffect} from 'react';
import {HomeStyle} from "./style";
import HomeBanner from "./cpns/home-banner";
import SectionHeader from "@/components/sectionHeader";
import SectionRooms from "../../components/sectionRooms";
import {shallowEqual, useDispatch, useSelector} from "react-redux";
import {fetchHomeDataAction} from "../../store/modules/home";

const Home = () => {

    const {goodPriceInfo} = useSelector(state => ({
        goodPriceInfo: state.home.goodPriceInfo,
    }), shallowEqual);

    const dispatch = useDispatch();
    useEffect(() => {
        dispatch(fetchHomeDataAction())
    }, [dispatch]);
    console.log(goodPriceInfo);

    return (
        <HomeStyle>
            <HomeBanner/>
            <div className='content'>
                <div className='good-price'>
                    <SectionHeader title={goodPriceInfo?.title}/>
                    <SectionRooms roomList={goodPriceInfo?.list} />
                </div>
            </div>
        </HomeStyle>
    );
};

export default Home;